/**
 * Created by ASUS on 2017/10/9.
 */
public class Test05 {
        private static int SumFor(int a){
            int sum = 0;
            for (int b = 1;b<a;b++){
                sum = sum +b;
            }
            return sum;
        }
        private static int SumDowhile(int a){
            int i=1;
            int sum=0;
            do{
                sum=sum+i;
                i++;
            }
            while(i<=a);
            return sum;
        }
        private static int SumWhile(int a){
            int i=1;
            int sum = 0;
            while (i<=a){
                sum = sum +i;
                i++;
            }
            return sum;
        }
        public static void main(String[] args) {
            System.out.println("For 方法求和结果为："+SumFor(10));
            System.out.println("While 方法求和结果为："+SumWhile(10));
            System.out.println("do-while 方法求和结果为："+SumDowhile(10));
        }
    }